package com.ljt.yupictureddd.shared.manager.websocket.model;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum PictureEditMessageTypeEnums {

    INFO("发送通知", "INFO"),
    ERROR("普通版", "ERROR"),
    ENTER_EDIT("进入编辑状态", "ENTER_EDIT"),
    EXIT_EDIT("退出编辑状态", "EXIT_EDIT"),
    EDIT_ACTION("执行编辑操作", "EDIT_ACTION");

    private final String text;

    private final String value;

    PictureEditMessageTypeEnums(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     *
     * @param value
     * @return
     */
    public static PictureEditMessageTypeEnums getEnumByValue(String value) {
        if (StrUtil.isEmpty(value)) {
            return null;
        }
        return Arrays.stream(PictureEditMessageTypeEnums.values())
                .filter(space -> space.getValue().equals(value))
                .findFirst()
                .get();
    }
}
